package com.ilovepostcard.data;

import java.io.File;
import java.io.IOException;
import java.io.Serializable;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import com.ilovepostcard.model.User;
import com.ilovepostcard.utils.Constants;
import com.ilovepostcard.utils.Utils;

public class Postcard implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -4014565176067248160L;
	public long      id;
	public User      user;
	public String    location;
	public String    postId;
	public int       showLocationFlag;
	public int       canBeFoundFlag;
	public String[]  tags;
	public String      createTime;
	public Bitmap    image;
	public String    comment;
	public double    latitude;
	public double    longitude;
	//private Bitmap    pcView;
	
	public void setTmpEditPCView(Bitmap b)
	{
		if(b == null) return ;
		
		try {
			Utils.saveBitmap(b,getTmpEditPCViewPath());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public Bitmap getTmpEditPCView()
	{
		return BitmapFactory.decodeFile(getTmpEditPCViewPath());
	}
	
	public String getTmpEditPCViewPath()
	{
		return com.ilovepostcard.utils.Constants.TEMP_EDITVIEW_IMAGE_PATH;
	}
	
	public void setTmpEditPC(Bitmap b)
	{
		if(b == null) return ;
		
		String folder = Constants.APP_DIR;
		File dataRoot = new File(folder);
		if(!dataRoot.exists())
			dataRoot.mkdir();
		
		try {
			Utils.saveBitmap(b,getTmpEditPCPath());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public Bitmap getTmpEditPC()
	{
		return BitmapFactory.decodeFile(getTmpEditPCPath());
	}
	
	public String getTmpEditPCPath()
	{
		return com.ilovepostcard.utils.Constants.TEMP_EDIT_IMAGE_PATH;
	}
	
	
	
	
	
	
	
	
}
